<?php
namespace app\api\controller\v1;

use think\Validate;
use app\api\validate\IDMustBePositiveInt;
use app\api\model\Banner as BannerModel;
use think\Exception;
use app\lib\exception\BannerMissException;

class Banner
{
    # 获取benner信息
    public function getBanner($id)
    {
        (new IDMustBePositiveInt())->goCheck();

        // $banner = BannerModel::getBannerById($id);
        $banner = BannerModel::with(['items','items.img'])->find($id);


        if($banner->isEmpty()){
            throw new BannerMissException();
        }
        return $banner;
    }
}
